@{
    // blog index
    if(Blog.DataObject.GetUserProfiles().Count<=0){
        Response.Redirect("~/Actions/Public/CreateFirstAdmin.cshtml");
    } 
    // get category from query string of the first one from category table
    dynamic categoryId = Request.QueryString["category"];
    categoryId = (!String.IsNullOrEmpty(categoryId) && StringExtensions.IsInt(categoryId) ) ? categoryId :Blog.DataObject.GetFirstCategoryId() ;
    // GET ARTICLES by categoryId
    PageData["Articles"]=Blog.DataObject.GetPublishedArticles(categoryId);
    // if only 1 article in the request category , redirect to detailed article view.
    if(PageData["Articles"].Count==1){
        Response.Redirect(@Href("~/Actions/Public/ShowArticle",PageData["Articles"][0].id));
    }
    var view = "~/Views/Public/_ListArticlesView.cshtml";
    @RenderPage(view);
}




